var slider = mui("#slider");

function go() {
	slider.slider({
		interval: 5000
	});
}
go();

var abc=GetQueryString("abc");
localStorage.setItem("abc",abc);
console.log(localStorage.getItem("abc"));
var arrlead = ['../daikuan/daikuan_jisu.html', '../daikuan/daikuan_dae.html', '../bank/credit_card.html', '../home/strategy.html'];
var muislideritem = document.getElementsByClassName('mui-slider-item');
var muislideritemf = document.getElementsByClassName('mui-slider-item');
var muislideriteml = document.getElementsByClassName('mui-slider-item');
var xfbanner = document.getElementById('xfbannerimg');
var xfbannerround = document.getElementById('xfbannerimground');
function get() {
	//轮播图
	$.ajax({
		type: 'get',
		url: httpAdress + '/api/index/banner/getbanner',
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {

			var mydata = data.data;
			console.log(JSON.stringify(data));
			var strbanner1 = '';
			for(var i = 0; i < mydata.length; i++) {
				$('<div class="swiper-slide">' +
					'<a>' +
					'<img class="xfbb" src="' + httpAdress + mydata[i].img + '">' +
					'</a>' +
					'</div>').appendTo("#xfbanner");

				function xf(i, b, data) {
					document.getElementsByClassName(b)[i].addEventListener('tap', function() {
						console.log(i)
						if(localStorage.getItem("userid")) {
							window.location.href = data.data[i].murl;
						} else {
							var aa = data.data[i].murl;
							console.log(aa)
							localStorage.setItem("xfhref", aa);
							window.location.href = '../../HTML/login/login.html?islogin=1';
						}
					})
				}
				xf(i, "swiper-slide", data);
			}
			var swiper = new Swiper('.swiper-container', {
				pagination: '.swiper-pagination',
				paginationClickable: true,
				loop: true,
				autoplay: 3000,
				speed: 800
			});
			//小喇叭

			//贷款类型
			$.ajax({
				type: 'get',
				url: httpAdress + '/api/borrow/type/gettype',
				contentType: "application/json; charset=utf-8",
				dataType: 'jsonp',
				jsonp: "callback",
				jsonpCallback: "successCallback",
				success: function(data) {
					var mydata = data.data;
					var strlead = "";
					console.log(JSON.stringify(data));
					for(var i = 0; i < mydata.length; i++) {
						strlead += '<li class="mui-table-view-cell daikuan_kinds">' +
							'<a href="../../HTML/daikuan/daikuan_new.html?kind=' + mydata[i].id + '&kind1=' + mydata[i].name + '">' +
							'<img class="kind_img" src="' + httpAdress + mydata[i].logo + '" />' +
							'<p>' + mydata[i].name + '</p></a></li>';
					}
					document.getElementById("xfnewkind").innerHTML = strlead;
					//红色框
					$.ajax({
						type: 'get',
						url: httpAdress + '/api/borrow/amount/getamount',
						contentType: "application/json; charset=utf-8",
						dataType: 'jsonp',
						jsonp: "callback",
						jsonpCallback: "successCallback",
						success: function(data) {
							var mydata = data.data;
							for(var i = 0; i < mydata.length; i++) {
								if(mydata[i].is_index == 1) {

									$('<div class="money_kind_block">' +
										'<a href="../../HTML/daikuan/daikuan_new.html?money1=' + mydata[i].money + '&money=' + mydata[i].id + '">' +
										'<div>'+
										'<p class="part1">' + mydata[i].money + '</p>' +
										'<p>' + mydata[i].info + '</p>' +
										'</div>' +
                                        '<img src="' + httpAdress + mydata[i].pic + '"/>' +
										'</a></div>').appendTo(".money_kind");
								}
							}
							//贷款推荐
							$.ajax({
								type: 'get',
								url: httpAdress + '/api/borrow/product/getindexproduct',
								contentType: "application/json; charset=utf-8",
								dataType: 'jsonp',
								jsonp: "callback",
								jsonpCallback: "successCallback",
								success: function(data) {
									var mydata = data.data;
									var str2 = '';
									for(var i = 0; i < mydata.length; i++) {

										$('<li class="mui-table-view-cell mui-media listb">' +
											'<a href="../../HTML/home/home_fast_detail.html?mproid=' + mydata[i].id + '&mdname=' + mydata[i].name + '&mdrate=' + mydata[i].rate + '">' +
											'<img class="mui-media-object mui-pull-left bank_loan" src="' + httpAdress + mydata[i].logo + '">' +
											'<div class="mui-media-body">' +
											'<span class="mui-media-body head">' + mydata[i].name + '</span>' +
											'<p class="mui-ellipsis details">' + mydata[i].reason + '</p>' +
											'<span class="num1 front">成功贷款人数</span><span class="num detail">' + mydata[i].count + '人</span>' +
											'</div>' +
											'<span class="mui-icon mui-icon-arrowright">' +
											'</a>' +
											'</li>').appendTo("#bordrecommend");
									}
									$.ajax({
										type: 'get',
										url: httpAdress + '/api/index/horn/gethorn',
										contentType: "application/json; charset=utf-8",
										dataType: 'jsonp',
										//	jsonp:"callbackParam",
										jsonp: "callback",
										jsonpCallback: "successCallback",
										success: function(data) {

											var mydata = data.data.info;
											console.log(JSON.stringify(data))
											$('#horn_people').html(data.data.people)
														$('.scrolltop_text').html(mydata[0]);
											console.log(mydata.length)
											var str1 = '';
											var num = 0;
											setInterval(
												function xfscroll() {
													$('.scrolltop_text').slideUp(1500, function() {
														$('.scrolltop_text').html(mydata[num]);
														$('.scrolltop_text').css('display', 'block');
														num++;
														if(num == mydata.length) {
															num = 0;
														}
													});
												}, 3000);
										},
										error: function() {
											mui.toast('加载失败，刷新一下');
										}
									});

								},
								error: function() {
									mui.toast('信用卡推荐加载失败，刷新一下');
								}
							});
						},
						error: function() {
							mui.toast('贷款推荐加载失败，刷新一下');
						}
					});
					//			结束

				},
				error: function() {
					mui.toast('加载失败，刷新一下');
				}
			});
		},

		error: function(e) {
			mui.toast('加载失败，刷新一下');
			console.log(e);
		}
	});
}
//			结束
get();


var bannerimg1 = document.getElementById('bannerimg1');
//在1s内连续按两次返回退出
//var first = null;
//mui.back = function() {
//	if(!first) {
//		first = new Date().getTime();
//		plus.nativeUI.toast('再按一次退出');
//		setTimeout(function() {
//			first = null;
//		}, 1500)
//	} else {
//		if(new Date().getTime() - first < 1500) {
//			plus.runtime.quit();
//		}
//	}
//}